package com.study.happystudy.po;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import lombok.Getter;

import java.io.IOException;
import java.util.List;

@Getter
@Data
public class Post {
    private int authorId;// 作者id
    private String userHeadPortrait;// 作者头像
    private String userNickname;// 作者昵称
    private int postId;// 帖子id
    private List<String> tags;// 帖子标签
    private String title;// 帖子标题
    private String content;// 帖子内容
    private List<String> images;// 帖子图片
    private String postingTime;// 发帖时间
    private int likeCount;// 点赞数
    private int commentCount;// 评论数
    private int viewCount;// 浏览数
    private List<String> likeUserAvatars;// 点赞用户头像

    public void setAuthorId(int authorId) {
        this.authorId = authorId;
    }

    public void setUserHeadPortrait(String userHeadPortrait) {
        this.userHeadPortrait = userHeadPortrait;
    }

    public void setUserNickname(String userNickname) {
        this.userNickname = userNickname;
    }

    public void setPostId(int postId) {
        this.postId = postId;
    }

    public void setTags(String json)  {
       ObjectMapper mp = new ObjectMapper();
       try {
           this.tags = mp.readValue(json, List.class);
       }catch (IOException e){
           e.printStackTrace();
       }
    }


    public void setTitle(String title) {
        this.title = title;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public void setImages(String json) {
        ObjectMapper mp = new ObjectMapper();
        try {
            this.images = mp.readValue(json, List.class);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public void setPostingTime(String postingTime) {
        this.postingTime = postingTime;
    }

    public void setLikeCount(int likeCount) {
        this.likeCount = likeCount;
    }

    public void setCommentCount(int commentCount) {
        this.commentCount = commentCount;
    }

    public void setViewCount(int viewCount) {
        this.viewCount = viewCount;
    }

    public int getAuthorId() {
        return authorId;
    }

    public String getUserHeadPortrait() {
        return userHeadPortrait;
    }

    public String getuserNickname() {
        return userNickname;
    }

    public int getPostId() {
        return postId;
    }

    public List<String> getTags() {
        return tags;
    }

    public String getTitle() {
        return title;
    }

    public String getContent() {
        return content;
    }

    public List<String> getImages() {
        return images;
    }

    public String getPostingTime() {
        return postingTime;
    }

    public int getLikeCount() {
        return likeCount;
    }

    public int getCommentCount() {
        return commentCount;
    }

    public int getViewCount() {
        return viewCount;
    }

    public List<String> getLikeUserAvatars() {
        return likeUserAvatars;
    }

    public void setLikeUserAvatars(List<String> likeUserAvatars) {
        this.likeUserAvatars = likeUserAvatars;
    }
}
